<?php

namespace App\Http\Controllers\Frontend;

use App\Http\Controllers\Controller;
use App\Http\Requests\Validators\Backend\AuthValidator;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;

/**
 * 小程序登陆/登出/认证相关
 */
class AuthController extends Controller
{
    const VALIDATOR = AuthValidator::class;

    /**
     * 手机号码登陆
     */
    public function phoneLogin(Request $request)
    {
        //参数验证
        $this->my_validate($request->only('phone', 'password'), 'loginRules');

        return parent::login($request->only("phone", "password"));
    }

    /**
     * 小程序直接登录
     */
    public function miniLogin(Request $request)
    {
        $code = $request->get('code');
        //获取小程序openid

        $openid = "1234567890";
        $token = $this->createTokenByOpenid($openid);

        return $token;
    }

    public function logout()
    {
        return parent::logout();
    }
}
